home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / Macintosh Sample Code / Sample Code Notes / SCN.017.TbltDrvr < prev    next >
Encoding:
Text File  |  1994-11-18  |  2.2 KB  |  51 lines  |  [TEXT/MPS ]

  1. Macintosh
  2. Sample Code Notes
  3. _____________________________________________________________________________
  4.                                                   Developer Technical Support
  5.  
  6. #17:    TbltDrvr
  7.  
  8. Written by:    Cameron Birse
  9.  
  10. Versions:            1.00                        April 1989
  11.  
  12. Components:            TbltDrvr.a                    April 1, 1989
  13. _____________________________________________________________________________
  14.  
  15. 'ADBS' resources are loaded and executed at boot time (before INIT 
  16. 31), and they are made of two main parts, the installation or 
  17. initialization code and the the actual driver.
  18.  
  19. In this example, the installation portion allocates memory in the 
  20. system heap for the service routine and the “optional data area.”  
  21. It installs the driver using the Apple Desktop Bus (ADB) Manager 
  22. call _SetADBInfo.
  23.  
  24. Generally speaking, ADB devices are intended to be user input 
  25. devices.  The ADB Manager polls the bus every 11 milliseconds to 
  26. see if a device has new user input data.  This polling is 
  27. accomplished by sending a talk R0 command to the last active 
  28. device.  The last active device is the last device that had data 
  29. to send to the host.  If another device has data, it can request a 
  30. poll by sending a service request signal to the host.
  31.  
  32. When a device has responded to a poll, the ADB Manager will call 
  33. the driver to process the data.  This call is done a interrupt 
  34. time (level 1), and the driver is passed the data, by getting a 
  35. pointer to a Pascal string which contains the actual data.
  36.  
  37. In this example, the data is in the form of a pointing device’s 
  38. coordinates and button state.  When the driver gets the data, it 
  39. stores the coordinate information in RawMouse and MTemp.  We stuff 
  40. both RawMouse and MTemp, because the tablet is an “absolute” 
  41. device.  It also checks the state of the button against MBState, 
  42. and if there has been a change, it will update MBState and post 
  43. either a mouse-up or mouse-down event, as appropriate.
  44.  
  45. Note:    This code demonstrates how to move the cursor 
  46.         position.  This information is meant for input
  47.         device drivers only; this technique should not
  48.         be used by applications to move the cursor.
  49.         Moving the cursor is bad user interface, and
  50.         nobody likes a bad user interface, so “Just Say No.”
  51.